<template>
  <div class="fenxiao-order user-vender-order">
    <dhsHeader v-if="mmxxStatus" :type="orderStatus" :Data="headerData" @clickStatus="clickStatus"></dhsHeader>
    <!-- 链动 start -->
    <dhsHeader v-else-if="link" :type="orderStatus" :link="link"
              :Data="headerData"></dhsHeader>
    <!-- 链动 end -->
    <!-- 三三复制 start -->
    <dhsHeader v-else-if="replicate" :type="orderStatus" :replicate="replicate"
              :Data="headerData"></dhsHeader>
    <!-- 三三复制 end -->
    <dhsHeader v-else-if="sphLive" :type="orderStatus" :sphLive="sphLive"
              :Data="headerData"></dhsHeader>
    <dhsHeader v-else :type="2"
               :Data="headerData"></dhsHeader>
    <div class="daili-nav">
      <div class="aGroup">
        <scroll class="wrapper wrapper-srcoll"
                ref="wrapper"
                :startX="0"
                :click="true"
                :scrollX="true"
                :scrollY="false"
                :eventPassthrough="'vertical'">
          <!-- 链动 start -->
          <div class="content" v-if="link">
            <van-button class="span" data-id="0"  @click="selectItem(0)" :color="type == 0 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>全部</i>
              <em>{{countAll}}</em>
            </van-button>
            <van-button class="span" data-id="1"  @click="selectItem(1)" :color="type == 1 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>未结算</i>
              <em>{{countPaid}}</em>
            </van-button>
            <van-button class="span" data-id="3"  @click="selectItem(3)" :color="type == 3 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>已结算</i>
              <em>{{countSuccess}}</em>
            </van-button>
          </div>
          <!-- 链动 end -->
          <!-- 三三复制 start -->
          <div class="content" v-else-if="replicate">
            <van-button class="span" data-id="1"  @click="selectItem(1)" :color="type == 1 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>全部</i>
              <em>{{arr[0]}}</em>
            </van-button>
            <van-button class="span" data-id="3"  @click="selectItem(3)" :color="type == 3 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>已付款</i>
              <em>{{arr[1]}}</em>
            </van-button>
            <van-button class="span" data-id="4"  @click="selectItem(4)" :color="type == 4 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>已确认收货</i>
              <em>{{arr[2]}}</em>
            </van-button>
          </div>
          <!-- 三三复制 end -->
          <div class="content" v-else>
            <van-button class="span" data-id="1"  @click="selectItem(1)" :color="type == 1 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>全部</i>
              <em>{{arr['1']}}</em>
            </van-button>
            <van-button class="span" data-id="2"  @click="selectItem(2)" :color="type == 2 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>未付款</i>
              <em>{{arr['2']}}</em>
            </van-button>
            <van-button class="span" data-id="3"  @click="selectItem(3)" :color="type == 3 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>已付款</i>
              <em>{{arr['3']}}</em>
            </van-button>
            <van-button class="span" data-id="4"  @click="selectItem(4)" :color="type == 4 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>已确认收货</i>
              <em>{{arr['4']}}</em>
            </van-button>
            <van-button v-if="sphLive" class="span" data-id="5"  @click="selectItem(5)" :color="type == 5 ? '#F30C23':'#999999'" plain hairline round type="primary">
              <i>退款订单</i>
              <em>{{arr['5']}}</em>
            </van-button>
          </div>
        </scroll>
      </div>
      <!-- 时间筛选 -->
      <date-search @SearchData='SearchData' v-if="!(nextLevelId && nextLevelId!='undefined')"></date-search>
      <!-- 搜索关键词 -->
      <div class="head-wrap">
        <div class="head-search-item">
          <input
            type="text"
            v-model="keywords"
            placeholder="请输入会员ID/昵称/商品名称/订单号"
            @confirm="searchGoodsEvent"
            ref="searchInput">
          <div class="icon" @click="searchGoodsEvent">
            <!-- <svg-icon icon-class="icon_search" /> -->
            <img class="icon_search" src="https://img.wifenxiao.com/h5-wfx/images/common/search-icon.png" alt="">
          </div>
        </div>
      </div>
    </div>
    <div class="new-data-select" v-if="nextLevelId && nextLevelId!='undefined'">
      <div class="achievement-header clearfix">
        <ul class="item fl">
          <li v-for="(item, index) in items"
              :key="index"
              @click="selectDate(item.code,item.type)" :class="[current == item.code ? 'cur' : '']">
            <span>{{item.name}}</span>
          </li>
        </ul>
        <!-- 选择了月/季度/年后才显示按条件查找 -->
        <ul class="date fr"
            @click="showData" v-if="selectedType">
          <li class="date_time" :class="show_date?'active':''">
            <span>{{info}}</span>
            <i class="icon-right date-hide"></i>
          </li>
        </ul>
      </div>

      <date-pop @cancel="cancelTime"
              @confirm="selectTime"
              :current="current"
              :timeData="dateInfo"
              v-if="show_date" class="select-time-detail"></date-pop>
    </div>
    <div class="user-list"
         v-show="list.length">
      <van-list v-model="loading"
                :finished="finished"
                :error.sync="error"
                error-text="请求失败，点击重新加载"
                finished-text=""
                @load="loadMore">
        <div v-for="(item, index) in list"
             :key="index"
             class="item">
          <div class="dhs-virtual-icon"
               v-if="item.is_dhs_virtual == '1'"></div>
          <div class="fxordertit clearfix">
            <span class="fl" v-if="link || replicate">订单日期：{{item.create_time}}&nbsp;</span>
            <span class="fl" v-else>订单日期：{{item.end_time}}&nbsp;</span>
            <span class="fl">付款日期：{{item.pay_time}}</span>
            <span class="fr"
                  v-if="link || replicate"
                  :class="[item.status == 3 ? 'ready' : '']">{{item.status == 3 ? '已结算' : '未结算'}}</span>
            <span class="fr"
                  v-else
                  :class="[item.status == 3 ? 'ready' : '']">{{item.status_name}}</span>
          </div>
          <div class="fxorderlst clearfix">
            <!-- 链路 start -->
            <template v-if="link || replicate">
              <div class="dxPic fl">
                <img :src="item.headimgurl"
                    v-if="item.headimgurl"
                    class="user"
                    width="100%" />
                <img :src="defaultPhotoImg"
                    v-else
                    class="user"
                    width="100%" />
              </div>
            </template>
            <template v-else>
              <div class="dxPic fl">
                <img :src="item.avthor"
                    v-if="item.avthor"
                    class="user"
                    width="100%" />
                <img :src="defaultPhotoImg"
                    v-else
                    class="user"
                    width="100%" />
              </div>
            </template>
            <div class="fxorderinfo fl" @click="onDetails(item)">
              <div v-if="is_Lazy_cat_dz" style="width: 100%">
                <p>订单编号：</p>
                <p>{{item.order_no}}</p>
              </div>
              <div>
                <p>昵称：</p>
                <p>{{link || replicate ? item.nickname : item.nick}}</p>
              </div>
              <!-- 链动 直推订单 平级订单不显示-->
              <div v-if="link">
                <template v-if="orderStatus !=2 && item.superior_money > 0">
                <p>{{chainingNameList.name_chaining_commission_superior}}：</p>
                <p>{{mSymbol.name}}{{item.superior_money}}</p>
                </template>
              </div>
              <!-- 三三复制 -->
              <div v-else-if="replicate">
                <template v-if="item.commission_superior > 0 && orderStatus ==1">
                <p>{{replicateName.name_replicate_commission_superior}}：</p>
                <p>{{mSymbol.name}}{{item.commission_superior}}</p>
                </template>
              </div>
              <div v-else>
                <p>姓名：</p>
                <p>{{item.receiver_name}}</p>
              </div>
              <div>
                <p>金额：</p>
                <p>{{mSymbol.name}}{{link || replicate?item.payment:item.money}}</p>
              </div>
              <!-- 链动 平级奖励 仅老板身份显示-->
              <div v-if="link">
                <div :class="item.is_level_frozen ? 'chaining_bg' :''" v-if="item.level_money > 0 && link == 1">
                <img v-if="item.is_level_frozen" src="https://img.wifenxiao.com/h5-wfx/images/chaining_bg.png">
                <p>{{chainingNameList.name_chaining_commission_level}}：</p>
                <p>{{mSymbol.name}}{{item.level_money}}<span v-if="link == 1 && orderStatus == 1" class="hz_tips" >(已划走)</span></p>
                </div>
                <template v-if="item.indirect_level_money > 0 && link == 1">
                  <p>间接平级奖励：</p>
                  <p>{{mSymbol.name}}{{item.indirect_level_money}}</p>
                </template>
              </div>
              <!-- 三三复制 -->
              <div v-if="replicate">
                <template v-if="item.commission_level > 0">
                <p>{{replicateName.name_replicate_commission_level}}：</p>
                <p>{{mSymbol.name}}{{item.commission_level}}</p>
                </template>
              </div>
              <div v-if="!ltsn_dz && !link && !replicate">
                <p>{{item.commission_name}}：</p>
                <p>{{mSymbol.name}}{{item.commission}}</p>
              </div>
              <div>
                <p>状态：</p>
                <p>{{link || replicate?item.status_name:item.order_status}}</p>
              </div>
              <div v-if="replicate">
                <template v-if="item.commission_top > 0">
                <p>{{replicateName.name_replicate_commission_top}}：</p>
                <p>{{mSymbol.name}}{{item.commission_top}}</p>
                </template>
              </div>
              <!-- 20240613 需求增加会员ID-->
              <div>
                <p>会员ID：</p>
                <p>{{item.user_id}}</p>
              </div>
              <!-- 链动 见点奖励 仅老板身份、下级订单显示--->
              <template v-if="link">
              <div :class="item.is_top_frozen ? 'chaining_bg' :''" v-if="orderStatus !=2 && item.top_money > 0 && link == 1">
                <img v-if="item.is_top_frozen" src="https://img.wifenxiao.com/h5-wfx/images/chaining_bg.png">
                <p>{{chainingNameList.name_chaining_commission_top}}：</p>
                <p>{{mSymbol.name}}{{item.top_money}}</p>
              </div>
              </template>
              <!-- 链动 start -->
              <div class="dzStyle" v-if="(link && isChainingDisplayAddress == 1) || replicate">
                <p>收货人信息：</p>
                <p>{{item.receiver_name}}{{item.receiver_mobile}}{{item.receiver_address}}</p>
              </div>
              <div class="dzStyle" v-if="item.express_name">
                <p>物流信息：</p>
                <p>{{item.express_name}}{{item.express_no}}</p>
              </div>
              <!-- 链动 营销费用 仅老板身份显示-->
              <div v-if="link">
                <template v-if="item.member_reward > 0 && link == 1">
                <p>营销费用：</p>
                <p>{{mSymbol.name}}{{item.member_reward}}</p>
                </template>
              </div>
              <!-- 链动 end -->

              <!--定制：上海梵迹 【手机端团队订单展示物流信息+收货人信息】 start-->
              <div class="dzStyle" v-if="item.receiver_name_dz">
                <p>收货人信息：</p>
                <p>{{item.receiver_name_dz}}{{item.receiver_mobile_dz}}{{item.receiver_address_dz}}</p>
              </div>
              <div class="dzStyle" v-if="item.express_name_dz">
                <p>物流信息：</p>
                <p>{{item.express_name_dz}}{{item.express_no_dz}}</p>
              </div>
              <!--定制：上海梵迹 【手机端团队订单展示物流信息+收货人信息】 end-->

              <p class="check_detail" v-if="!is_Lazy_cat_dz">
                <van-button  class="send-btn" color="#F30C23" plain hairline round type="primary"
                 @click="Jump('venderOrderDetail',{order_id:item.order_id})">查看订单商品明细</van-button>
                <van-button  class="send-btn" color="#F30C23" plain hairline round type="primary" style="margin-left:4px;" @click="toCommentList(item.order_item_count,item.order_id,item.order_item_ids)" v-if="headerData.dhs_order_detail_info==1">原价分享</van-button>
                <!-- <svg-icon icon-class="icon_right"
                          class="all-class-icon"></svg-icon> -->
              </p>
            </div>
          </div>
        </div>
      </van-list>
    </div>
    <div v-show="!list.length && finished" >
      <no-data :noData="noData"></no-data>
    </div>
  </div>
</template>

<script>
import dhsHeader from '@/views/user/dhs/components/dhsHeader/index'
import noData from '@/components/noData/index'
import Scroll from '@/components/scroll/index'
import dateSearch from './components/dateSearch/index'
import { getVenderOrder } from '@/api/user/dhs/dhsApi'
import datePop from '@/views/user/components/datePop'
import { chainingOrder } from '@/api/user/link/index'
import { replicateOrder } from '@/api/user/replicate/index'
import { mapGetters } from 'vuex'
import Vue from 'vue'
export default Vue.extend({
  data() {
    return {
      defaultPhotoImg: 'https://img.wifenxiao.com/h5-wfx/images/user/default_photo_img.jpg',
      headerData: {
      },
      arr: {
      },
      type: 1,
      p: 2,
      noData: {
        text: '暂无订单',
        img: 'https://img.wifenxiao.com/h5-wfx/images/user/no_order_data.png',
        marginTop: '5em'
      },
      items: [
        {
          name: '月',
          code: 1,
          type: 'month'
        },
        {
          name: '季度',
          code: 2,
          type: 'quarter'
        },
        {
          name: '年',
          code: 0,
          type: 'year'
        }
      ],
      dateInfo: {
        year: {},
        quarter: {},
        month: {},
        currentYear: '',
        currentMonth: '',
        selectQuarter: '',
        goodsType: 1
      },
      current: -1, // -1没有默认，1月，2季度，0年
      selectedType: '',
      show_date: false,
      info: '按条件查找',
      loading: false,
      finished: false,
      error: false,
      list: [],
      startData: '',
      endDate: '',
      // 莱特妮丝定制
      ltsn_dz: false,
      // 妈妈心选
      orderStatus: 2,
      mmxxStatus: false,
      is_own_order: 0,
      nextLevelId: '',
      keywords: '', // 搜索关键词
      search_name_dz: 0, // 定制 可以名称搜索
      link: 0,
      isChainingDisplayAddress: 0,
      countAll: 0,
      countPaid: 0,
      countSuccess: 0,
      sphLive: 0, // 视频号数据
      chainingNameList: {
        name_chaining_commission_level: '', // 平级奖
        name_chaining_commission_superior: '', // 直推奖
        name_chaining_commission_top: '' // 见点奖
      },
      replicate: 0,
      replicateName: {},
      is_Lazy_cat_dz: 0 // 懒猫定制
    }
  },
  watch: {
    '$route.query.type': {
      handler(newVal, oldVal) {
        if (newVal != oldVal) {
          if (this.$route.query.link) {
          this.orderStatus = newVal
          // 链动
          if (this.$route.query.link) {
            if (this.$route.query.link == 1) {
              this.link = 4
            } else if (this.$route.query.link == 2) {
              this.link = 1
            }
            this.orderStatus = this.$route.query.type
            wx.setNavigationBarTitle({
              title: ''
            })
          }
          this.init()
          this.is_dz()
          } else if (this.$route.query.replicate) {
            this.orderStatus = newVal
            // 三三复制
            if (this.$route.query.replicate) {
              if (this.$route.query.link == 1) {
                this.replicate = 4
              } else if (this.$route.query.link == 2) {
                this.replicate = 1
              }
              this.orderStatus = this.$route.query.type
              wx.setNavigationBarTitle({
                title: ''
              })
            }
            this.init()
            this.is_dz()
          }
        }
      }
    },
    deep: true
  },

  created() {
    this.getTime()
    // 莱特妮丝定制
    const shop = this.$route.query.sid
    const ltsn_dz = this.$_shop('$_ltsn_dz', shop)
    this.ltsn_dz = ltsn_dz
    // 妈妈心选
    let mmxxStatus = window.sessionStorage.getItem('mmxxStatus') || ''
    mmxxStatus = Number(mmxxStatus)
    if (mmxxStatus == 3) {
      this.orderStatus = 3
      this.is_own_order = 1
    }
    const mmxx = this.$_shop('$_mmxx', shop)
    this.mmxxStatus = mmxx
    if (this.mmxxStatus) {
      const is_own_order = this.is_own_order
      this.init({ is_own_order })
    } else {
      this.init()
    }
  },
  mounted() {
    // TODO 小程序触底加载更多
    window.addEventListener('reachbottom', () => {
      this.loadMore()
    })
  },
  beforeDestroy() {
    window.sessionStorage.removeItem('mmxxStatus')
  },
  methods: {
    onDetails(item) {
      if (this.is_Lazy_cat_dz) {
        this.Jump('venderOrderDetail', { order_id: item.order_id, is_Lazy_cat_dz: this.is_Lazy_cat_dz })
      }
    },
    init(data) {
      // 视频号数据
      this.sphLive = this.$route.query.type == 'live' ? 1 : 0

      // 链动 start
      if (this.$route.query.link) {
        if (this.$route.query.link == 1) {
          this.link = 4
        } else if (this.$route.query.link == 2) {
          this.link = 1
        }
        this.orderStatus = this.$route.query.type
        this.type = this.$route.query.settleType || 0
        if (this.$route.query.userId) {
          this.keywords = this.$route.query.userId
        }
        wx.setNavigationBarTitle({
          title: ''
        })
      }
      // 链动 end
      // 三三复制 start
      if (this.$route.query.replicate) {
        if (this.$route.query.replicate == 1) {
          this.replicate = 4
        } else if (this.$route.query.replicate == 2) {
          this.replicate = 1
        }
        this.orderStatus = this.$route.query.type
        this.type = this.$route.query.settleType || 1
        if (this.$route.query.userId) {
          this.keywords = this.$route.query.userId
        }
        wx.setNavigationBarTitle({
          title: ''
        })
      }
      // 三三复制 end

      this.$loadingWrap.show()
      this.p = 2
      this.finished = false
      const params = this.getParams()
      if (this.link) {
        this.$loadingWrap.show()
        this.list = []
        const data = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        chainingOrder(data).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            wx.setNavigationBarTitle({
              title: res.data.chaining_action_name || '链动订单'
            })
            // 按钮
            this.countAll = res.data.countAll
            this.countPaid = res.data.countPaid
            this.countSuccess = res.data.countSuccess
            // 自定义名称
            this.chainingNameList = res.data.chainingNameList
            // 列表
            this.list = res.data.list
            this.isChainingDisplayAddress = res.data.isChainingDisplayAddress
            if (!this.list.length) {
              this.finished = true
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      if (this.replicate) {
        this.$loadingWrap.show()
        this.list = []
        const data = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        replicateOrder(data).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            wx.setNavigationBarTitle({
              title: res.data.name_info.name_replicate_order || '复制订单'
            })
            // 自定义名称
            this.replicateName = res.data.name_info
            this.arr = res.data.number_info
            // 列表
            this.list = res.data.list
            if (!this.list.length) {
              this.finished = true
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      getVenderOrder({
        ...params,
        is_video_order: this.sphLive == 1 ? 1 : undefined
        }).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          wx.setNavigationBarTitle({
            title: res.data.ftitle_dhs_user
          })
          if (this.sphLive) {
            document.title = '视频号数据'
            wx.setNavigationBarTitle({
              title: '视频号数据'
            })
          }
          // 头部和导航数据
          this.headerData = res.data
          // select的option的年、月、季度
          this.dateInfo.year = res.data.year_list
          this.dateInfo.month = res.data.month
          this.dateInfo.quarter = res.data.quarter
          this.is_Lazy_cat_dz = res.data.is_Lazy_cat_dz
          // 定制 名称搜索
          this.search_name_dz = res.data.search_name_dz || 0
          // 按钮
          this.arr = res.data.arr
          // 列表
          this.list = res.data.order_list
          if (!this.list.length) {
            this.finished = true
          }
        } else {
          this.$Error(res.mag)
        }
      })
    },
    getParams(data) {
      const value =
        this.current == 1
          ? this.dateInfo.currentMonth
          : this.current == 2
            ? this.dateInfo.currentQuarter
            : ''

      const selectedData = {
        selectedType: this.selectedType,
        value,
        year: this.dateInfo.currentYear,
        order_no: this.keywords
      }
      const nextLevelParams = {}
      if (this.$route.query.nextLevelId) {
        this.nextLevelId = nextLevelParams.nextLevelId = this.$route.query.nextLevelId
      }
      const params = Object.assign({}, data, nextLevelParams, selectedData)
      return params
    },
    // 获取当前年份、月份、季度
    getTime() {
      const time = new Date()
      const currentYear = time.getFullYear()
      const currentMonth = time.getMonth() + 1
      const currentQuarter = Math.ceil(currentMonth / 3)
      this.dateInfo.currentYear = currentYear
      this.dateInfo.currentMonth = currentMonth
      this.dateInfo.currentQuarter = currentQuarter
    },
    // 切换年份、月份、季度
    selectDate(code, type) {
      this.getTime()
      // this.cancelTime()
      this.current = code
      this.selectedType = type
      this.init()
    },
    // 点击按条件查找
    showData() {
      this.show_date = !this.show_date
    },
    // 选择具体年月季度
    selectTime(e) {
      this.dateInfo.currentYear = e.selectYear
      this.dateInfo.currentMonth = e.selectMonth
      this.dateInfo.currentQuarter = e.selectQuarter
      this.show_date = false
      this.init()
    },
    // 点击取消按钮
    cancelTime() {
      this.show_date = false
    },
    // 加载更多
    loadMore() {
      const data = {
        p: this.p,
        type: this.type,
        search_start_time: this.startData,
        search_end_time: this.endDate
      }
      if (this.mmxxStatus) {
        data.is_own_order = this.is_own_order
      }
      const params = this.getParams(data)
      if (this.link) {
        const data = {
          p: this.p,
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        chainingOrder(data).then(res => {
        this.loading = false
        this.isChainingDisplayAddress = res.data.isChainingDisplayAddress
        if (res.data.list.length) {
          this.list = this.list.concat(res.data.list)
          this.p++
        } else {
          this.finished = true
        }
      }).catch(() => {
        this.error = true
      })
        return false
      }
      if (this.replicate) {
        const data = {
          p: this.p,
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        replicateOrder(data).then(res => {
          if (res.status == 1) {
            this.loading = false
            if (res.data.list.length) {
              this.list = this.list.concat(res.data.list)
              this.p++
            } else {
              this.finished = true
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      getVenderOrder({
        ...params,
        is_video_order: this.sphLive == 1 ? 1 : undefined
        }).then(res => {
        this.loading = false
        if (res.data.length) {
          this.list = this.list.concat(res.data)
          this.p++
        } else {
          this.finished = true
        }
      }).catch(() => {
        this.error = true
      })
    },
    // 切换类型
    selectItem(type) {
      if (this.type == type) return
      this.type = type
      this.p = 2
      const data = {
        type: type
      }
      if (this.mmxxStatus) {
        data.is_own_order = this.is_own_order
      }
      const params = this.getParams(data)
      this.$loadingWrap.show()
      this.finished = false
      if (this.link) {
        const data = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        chainingOrder(data).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            wx.setNavigationBarTitle({
              title: res.data.chaining_action_name || '链动订单'
            })
            // 按钮
            this.countAll = res.data.countAll
            this.countPaid = res.data.countPaid
            this.countSuccess = res.data.countSuccess
            // 自定义名称
            this.chainingNameList = res.data.chainingNameList
            // 列表
            this.list = res.data.list
            this.isChainingDisplayAddress = res.data.isChainingDisplayAddress
            if (!this.list.length) {
              this.finished = true
            } else {
              this.finished = false
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      if (this.replicate) {
        const data = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        replicateOrder(data).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            document.title = res.data.name_info.name_replicate_order || '复制订单'
            // 自定义名称
            this.replicateName = res.data.name_info
            this.arr = res.data.number_info
            // 列表
            this.list = res.data.list
            if (!this.list.length) {
              this.finished = true
            } else {
              this.finished = false
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      getVenderOrder({
        ...params,
        is_video_order: this.sphLive == 1 ? 1 : undefined
        }).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          // 列表
          this.list = res.data.order_list
          this.headerData.agency_order_total = res.data.agency_order_total
          if (!this.list.length) {
            this.finished = true
          } else {
            this.finished = false
          }
        } else {
          this.$Error(res.mag)
        }
      })
    },
    // 时间查找
    SearchData(startData, endDate) {
      this.startData = startData
      this.endDate = endDate
      const data = {
        type: this.type,
        search_start_time: startData,
        search_end_time: endDate,
        order_no: this.keywords
      }
      if (this.mmxxStatus) {
        data.is_own_order = this.is_own_order
      }
      this.$loadingWrap.show()
      if (this.link) {
        const data1 = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        chainingOrder(data1).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            wx.setNavigationBarTitle({
              title: res.data.chaining_action_name || '链动订单'
            })
            // 按钮
            this.countAll = res.data.countAll
            this.countPaid = res.data.countPaid
            this.countSuccess = res.data.countSuccess
            // 自定义名称
            this.chainingNameList = res.data.chainingNameList
            // 列表
            this.list = res.data.list
            this.isChainingDisplayAddress = res.data.isChainingDisplayAddress
            if (!this.list.length) {
              this.finished = true
            } else {
              this.finished = false
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      if (this.replicate) {
        const data = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        replicateOrder(data).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            document.title = res.data.name_info.name_replicate_order || '复制订单'
            // 自定义名称
            this.replicateName = res.data.name_info
            this.arr = res.data.number_info
            // 列表
            this.list = res.data.list
            if (!this.list.length) {
              this.finished = true
            } else {
              this.finished = false
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      getVenderOrder({
        ...data,
        is_video_order: this.sphLive == 1 ? 1 : undefined
        }).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          // 列表
          this.list = res.data.order_list
          this.headerData.agency_order_total = res.data.agency_order_total
          if (!this.list.length) {
            this.finished = true
          } else {
            this.finished = false
          }
        } else {
          this.$Error(res.mag)
        }
      })
    },
    // 跳转详情
    // 跳转详情
    Jump(path, data) {
      // const path = 'venderOrderDetail'
      this.$JumpPath(this, path, data)
    },
    // 点击原价分享
    toCommentList(length, order_id, order_item_ids) {
      let path = ''
      const query = {
        type: 'price'
      }
      // 原价分享只有一个商品的时候直接跳转分享晒单页面不走中间页
      if (length == 1) {
        path = 'shareOrder'
        query.itemId = order_item_ids
      } else {
        path = 'commentList'
        query.orderId = order_id
        query.dhsVenderOrder = 1
      }
      this.Jump(path, query)
    },
    clickStatus(status) {
      this.orderStatus = status
      if (this.orderStatus == 2) {
        this.is_own_order = 0
      } else {
        this.is_own_order = 1
      }
      const is_own_order = this.is_own_order
      this.p = 2
      this.list = []
      this.loading = false
      this.finished = false
      this.error = false
      this.type = 1
      this.init({ is_own_order })
    },
    // 根据会员id/昵称/商品名称/订单号进行搜索
    searchGoodsEvent() {
      this.$refs.searchInput.blur()
      this.p = 2
      const params = {
        type: this.type,
        search_start_time: this.startData,
        search_end_time: this.endDate,
        order_no: this.keywords
      }
      this.$loadingWrap.show()
      if (this.link) {
        const data1 = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        chainingOrder(data1).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            wx.setNavigationBarTitle({
              title: res.data.chaining_action_name || '链动订单'
            })
            // 按钮
            this.countAll = res.data.countAll
            this.countPaid = res.data.countPaid
            this.countSuccess = res.data.countSuccess
            // 自定义名称
            this.chainingNameList = res.data.chainingNameList
            // 列表
            this.list = res.data.list
            this.isChainingDisplayAddress = res.data.isChainingDisplayAddress
            if (!this.list.length) {
              this.finished = true
            } else {
              this.finished = false
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      if (this.replicate) {
        const data = {
          title: this.keywords,
          status: this.type,
          type: this.orderStatus,
          start_time: this.startData,
          end_time: this.endDate
        }
        replicateOrder(data).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            document.title = res.data.name_info.name_replicate_order || '复制订单'
            // 自定义名称
            this.replicateName = res.data.name_info
            this.arr = res.data.number_info
            // 列表
            this.list = res.data.list
            if (!this.list.length) {
              this.finished = true
            } else {
              this.finished = false
            }
          } else {
            this.$Error(res.mag)
          }
        })
        return false
      }
      getVenderOrder({
        ...params,
        is_video_order: this.sphLive == 1 ? 1 : undefined
        }).then(res => {
        this.$loadingWrap.close()
        this.loading = false
        if (res.status == 1) {
          this.list = res.data.order_list
          this.headerData.agency_order_total = res.data.agency_order_total
          if (!this.list.length) {
            this.finished = true
          } else {
            this.finished = false
          }
        } else {
          this.$Error(res.mag)
        }
      }).catch(() => {
        this.error = true
      })
    }
  },
  components: {
    dhsHeader,
    noData,
    Scroll,
    dateSearch,
    datePop
  },
  computed: {
    // 获取自定义符号
    ...mapGetters(['mSymbol'])
  }
})
</script>

<style lang="scss">
@import "src/styles/variables";
@import "src/styles/user/Group/index";
@import "src/styles/user/orderList/index";
@import "src/styles/user/yejiStyle/index";
.user-vender-order{
  .daili-nav {
    border-top: 1px solid #ededed;
    padding: 10px 30px;
    background: #fff;
    .wrapper-srcoll{
      overflow-x: scroll;
    }
  }
  .head-wrap{
    .head-search-item{
      position: relative;
      width: 100%;
      height: 60px;
      border-radius: 20px;
      border: 2px solid #EDEDED;
      background: rgba(242,242,242,0.35);
      overflow: hidden;
      input {
        padding: 0 14px 0 58px;
        width: 100%;
        height: 100%;
        color: #999999;
      }
      .icon {
        position: absolute;
        left: 16px;
        top: 16px;
        color: #999999;
        font-size: 28px;
        margin-right: 14px;
        .icon_search{
          width:28px;
          height:28px;
        }
      }
    }
  }
  .user-list .item .fxorderlst .fxorderinfo div.dzStyle{
    width:100%;
    height:auto;
    -webkit-line-clamp:initial;
    line-clamp:initial;
  }
  .new-data-select{
    padding:10px 0 36px;
    border-radius:0 0 20px 20px;
    background:#fff;
    .achievement-header{
      margin-bottom:0;
      .date{
        .date_time{
          //小程序特殊处理
          .date-hide{
            transform:translate(50%,-25%) rotateZ(45deg);
          }
          &.active{
            .date-hide{
              transform:translate(50%,0) rotateZ(-135deg);
            }
          }
        }
      }
    }
    .date-pop{
      position: initial;
      .content{
        background:#fff;
      }
      .btn{
        box-shadow:none;
        .cancel-btn{
          border-top:2px solid #EDEDED;
          border-bottom:2px solid #EDEDED;
        }
      }
    }
  }
}
.hz_tips {
  color: red;
  font-size: 20px;
}
.chaining_bg {
  position: relative;
  img {
    position: absolute;
    right: 0;
    height: 35px;
  }
}
</style>
